package com.boluo.web.controller.businessManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.boluo.businessManagement.dto.BusMentStoreDTO;
import com.boluo.common.core.domain.entity.BMGoodsCategory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boluo.common.annotation.Log;
import com.boluo.common.core.controller.BaseController;
import com.boluo.common.core.domain.AjaxResult;
import com.boluo.common.enums.BusinessType;
import com.boluo.businessManagement.domain.BusMentGoodsCategory;
import com.boluo.businessManagement.service.IBusMentGoodsCategoryService;
import com.boluo.common.utils.poi.ExcelUtil;
import com.boluo.common.core.page.TableDataInfo;

/**
 * 物品分类信息Controller
 * 
 * @author boluo
 * @date 2023-05-02
 */
@RestController
@RequestMapping("/businessManagement/category")
public class BusMentGoodsCategoryController extends BaseController
{
    @Autowired
    private IBusMentGoodsCategoryService busMentGoodsCategoryService;

    /**
     * 查询物品分类信息列表不分页
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:list')")
    @GetMapping("/listNoPage")
    public AjaxResult listNoPage()
    {
        List<BusMentGoodsCategory> list = busMentGoodsCategoryService.selectBusMentGoodsCategorylistNoPage();
        return AjaxResult.success(list);
    }
    /**
     * 获取部门下拉树列表
     */
    @GetMapping("/treeselect")
    public AjaxResult treeselect() {
        List<BMGoodsCategory> list = busMentGoodsCategoryService.selectBMGoodsCategoryList();
        return AjaxResult.success(busMentGoodsCategoryService.buildDeptTreeSelect(list));
    }

    /**
     * 查询物品分类信息列表
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusMentStoreDTO busMentStoreDTO)
    {
        startPage();
        List<BusMentGoodsCategory> list = busMentGoodsCategoryService.selectBusMentGoodsCategoryList(busMentStoreDTO);
        return getDataTable(list);
    }



    /**
     * 获取物品分类信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(busMentGoodsCategoryService.selectBusMentGoodsCategoryById(id));
    }

    /**
     * 新增物品分类信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:add')")
    @Log(title = "物品分类信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusMentGoodsCategory busMentGoodsCategory)
    {
        return toAjax(busMentGoodsCategoryService.insertBusMentGoodsCategory(busMentGoodsCategory));
    }

    /**
     * 修改物品分类信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:edit')")
    @Log(title = "物品分类信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusMentGoodsCategory busMentGoodsCategory)
    {
        return toAjax(busMentGoodsCategoryService.updateBusMentGoodsCategory(busMentGoodsCategory));
    }

    /**
     * 删除物品分类信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:category:remove')")
    @Log(title = "物品分类信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(busMentGoodsCategoryService.deleteBusMentGoodsCategoryById(id));
    }
}
